#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["UserCenter/HelenServer.UserCenter.Web/HelenServer.UserCenter.Web.csproj", "UserCenter/HelenServer.UserCenter.Web/"]
COPY ["UserCenter/HelenServer.UserCenter.Controllers/HelenServer.UserCenter.Controllers.csproj", "UserCenter/HelenServer.UserCenter.Controllers/"]
COPY ["UserCenter/HelenServer.UserCenter.Contracts/HelenServer.UserCenter.Contracts.csproj", "UserCenter/HelenServer.UserCenter.Contracts/"]
COPY ["HelenServer.Core/HelenServer.Core.csproj", "HelenServer.Core/"]
COPY ["UserCenter/Authentication/HelenServer.UserCenter.Authentication/HelenServer.UserCenter.Authentication.csproj", "UserCenter/Authentication/HelenServer.UserCenter.Authentication/"]
COPY ["UserCenter/HelenServer.UserCenter.Dal/HelenServer.UserCenter.Dal.csproj", "UserCenter/HelenServer.UserCenter.Dal/"]
COPY ["HelenServer.Grpc.Contracts/HelenServer.Grpc.Contracts.csproj", "HelenServer.Grpc.Contracts/"]
COPY ["HelenServer.Data.SqlServer/HelenServer.Data.SqlServer.csproj", "HelenServer.Data.SqlServer/"]
COPY ["HelenServer.Dapr/HelenServer.Dapr.csproj", "HelenServer.Dapr/"]
COPY ["UserCenter/HelenServer.UserCenter.Services/HelenServer.UserCenter.Services.csproj", "UserCenter/HelenServer.UserCenter.Services/"]
RUN dotnet restore "UserCenter/HelenServer.UserCenter.Web/HelenServer.UserCenter.Web.csproj"
COPY . .
WORKDIR "/src/UserCenter/HelenServer.UserCenter.Web"
RUN dotnet build "HelenServer.UserCenter.Web.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "HelenServer.UserCenter.Web.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HelenServer.UserCenter.Web.dll"]